// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import 'babel-polyfill'
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI from 'element-ui'
import '../node_modules/element-ui/lib/theme-chalk/index.css'
import '../static/css/common.css'
import VueCropper from 'vue-cropper'
import axios from 'axios'
import md5 from 'js-md5'
import store from './vuex/store.js'
import config from './config.js'
import echarts from 'echarts'
import {
    Message
} from 'element-ui';
Vue.config.productionTip = false
Vue.prototype.$axios = axios
Vue.prototype.$md5 = md5
Vue.prototype.$Message = Message
Vue.prototype.$baseUrl = config.baseUrl
Vue.prototype.$baseUrl3 = config.baseUrl3
Vue.prototype.$baseUrl4 = config.baseUrl4
Vue.prototype.$echarts = echarts;
Vue.use(ElementUI)
Vue.use(VueCropper)

Vue.prototype.$md5 = md5;
Vue.prototype.$photoUrl = localStorage.photoUrl
Vue.prototype.$monitorQuery = localStorage.monitorQuery?JSON.parse(localStorage.monitorQuery): {
    comid: '',
    pid: ''
}
import Print from './print.js'
Vue.use(Print)


// axios.interceptors.request.use(config => {
//   let Token = localStorage.getItem('token');
//   let userId = localStorage.getItem('userid')
//   config.headers.common['Token'] = Token || ''
//   config.headers.common['userId'] = userId || ''
//   return config
// })
// var getLastUrl=(str,yourStr)=>str.slice(str.lastIndexOf(yourStr))
// router.beforeEach((to, from, next) => {
//   if (localStorage.getItem('new')) {
//     var c = JSON.parse(localStorage.getItem('new')),
//     lastUrl=getLastUrl(window.location.href,'/');
//       let newRoutes = c ;
//       // localStorage.removeItem('new')
//       debugger;
//       router.addRoutes(newRoutes)
//     }
//     next()
// })
Vue.prototype.postData = function (n, param1, param2, param3, param4, param5, param6) {
    let url = config.baseUrl
    let param = {}
    if (n == 0) {
        url += 'emergency/v1.0/review/info'
        param = {
            planSummaryId: localStorage.planid,
            tableType: param1,
            userId: localStorage.userid
        }
    } else if (n == 1) {
        url += 'emergency/v1.0/view/summary/plan/' + localStorage.planid
    } else {
        url += 'emergency/v1.0/review/save'
        param = {
            mapList: param2,
            planSummaryId: localStorage.planid,
            reviewTemplateName: localStorage.planname,
            reviewType: param1,
            autograph: param3,
            userId: localStorage.userid,
            opinion: param4,
            remarks: param5,
            organizationName: param6
        }
    }
    return new Promise((resolve, reject) => {
        if (n == 1) {
            this.$axios
                .get(url)
                .then(res => {
                    resolve(res)
                })
                .catch(res => {
                    reject(res)
                });
        } else {
            this.$axios
                .post(url, param)
                .then(res => {
                    resolve(res)
                })
                .catch(res => {
                    reject(res)
                });
        }

    })
}

/* eslint-disable no-new */
new Vue({
    el: '#app',
    router,
    store,
    components: {
        App
    },
    template: '<App/>'
})
